package cn.iocoder.yudao.module.scenic.dal.mysql.spot;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.scenic.controller.admin.spot.vo.SpotPageReqVO;
import cn.iocoder.yudao.module.scenic.dal.dataobject.spot.SpotDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 实践点 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface SpotMapper extends BaseMapperX<SpotDO> {

    default PageResult<SpotDO> selectPage(SpotPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SpotDO>()
                .likeIfPresent(SpotDO::getName, reqVO.getName())
                .eqIfPresent(SpotDO::getDescription, reqVO.getDescription())
                .eqIfPresent(SpotDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(SpotDO::getContact, reqVO.getContact())
                .eqIfPresent(SpotDO::getContactNumber, reqVO.getContactNumber())
                .eqIfPresent(SpotDO::getIsOpen, reqVO.getIsOpen())
                .eqIfPresent(SpotDO::getOpenTime, reqVO.getOpenTime())
                .eqIfPresent(SpotDO::getProvinceId, reqVO.getProvinceId())
                .eqIfPresent(SpotDO::getCityId, reqVO.getCityId())
                .eqIfPresent(SpotDO::getDistrictId, reqVO.getDistrictId())
                .eqIfPresent(SpotDO::getPhotoUrl, reqVO.getPhotoUrl())
                .eqIfPresent(SpotDO::getVideoUrl, reqVO.getVideoUrl())
                .betweenIfPresent(SpotDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(SpotDO::getId));
    }

}